package molydb

import (
	"io"
	"molydb/opt"
	"molydb/storage"
)

type DB struct {
	closer io.Closer
}

func Open(stor storage.Storage, o *opt.Options) (db *DB, err error) {
	s,err := newSession(stor,o)
}

func OpenFile(path string, o *opt.Options) (db *DB, err error) {
	stor, err := storage.OpenFile(path, o.GetReadOnly())

	if err != nil {
		return
	}

	db, err = Open(stor, o)

	if err != nil {
		stor.Close()
	} else {
		db.closer = stor
	}
	return
}
